package com.hf.lookatme.zview.adapters;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.hf.lookatme.R;
import com.hf.lookatme.utils.DisplayUtils;
import com.hf.lookatme.zbean.GuessYourLikeData;

import java.util.List;
import java.util.zip.Inflater;

/**
 * 描述：猜你喜欢 的Adapter
 * 创建人：JoeShiguang
 * 创建日期：2015/6/24
 * 修改人：
 * 修改日期：
 *
 * @Version 1.0
 */
public class Adapter_RecyclerView_GuessYourLike extends RecyclerView.Adapter<ViewHolder_GuessYourLike> {

  private Context context;
  private List<GuessYourLikeData> list_guessData;
  private LayoutInflater inflater;
  private onItemClickListener onItemClickListener;

  public interface onItemClickListener{
    void onItemClick(View view, int position);
  }
  public void setOnItemClickListener(onItemClickListener listener){
    this.onItemClickListener = listener;
  }

  public Adapter_RecyclerView_GuessYourLike(Context context, List<GuessYourLikeData> list_guessData) {
    this.context = context;
    this.list_guessData = list_guessData;
    this.inflater = LayoutInflater.from(context);
  }

  @Override
  public int getItemCount() {
    return list_guessData.size();
  }

  @Override
  public ViewHolder_GuessYourLike onCreateViewHolder(ViewGroup parent, int viewType) {

    //View view = DisplayUtils.getView(context, R.layout.layout_item_recyclerview_guessyourlike);
    View view = inflater.inflate(R.layout.layout_item_recyclerview_guessyourlike, parent, false);
    ViewHolder_GuessYourLike holder = new ViewHolder_GuessYourLike(view);
    return holder;
  }

  @Override
  public void onBindViewHolder(final ViewHolder_GuessYourLike holder, final int position) {

    /*if (list_guessData.get(position).getTypeColor() == 0) {

      holder.textView_type.setBackgroundResource(R.drawable.style_background_roundrectangle_color_blue);
    } else if (list_guessData.get(position).getTypeColor() == 1) {

      holder.textView_type.setBackgroundResource(R.drawable.style_background_roundrectangle_color_red);
    } else if (list_guessData.get(position).getTypeColor() == 2) {

      holder.textView_type.setBackgroundResource(R.drawable.style_background_roundrectangle_color_yellow);
    }*/
    /*if (list_guessData.get(position).isVerified()) {
      holder.textView_status.setVisibility(View.INVISIBLE);
      holder.textView_status.setText(context.getResources().getString(R.string.verified));
    } else {
      holder.textView_status.setVisibility(View.VISIBLE);
    }
    holder.textView_type.setText(list_guessData.get(position).getType());
    holder.textView_name.setText(list_guessData.get(position).getName());
    holder.textView_date.setText(list_guessData.get(position).getDate());
    holder.textView_contextMark.setText(list_guessData.get(position).getContextMark());
    holder.textView_contextPreview.setText(list_guessData.get(position).getContextPreview());

    holder.itemView.setOnClickListener(new View.OnClickListener() {
      @Override
      public void onClick(View v) {
        if(onItemClickListener != null){
          onItemClickListener.onItemClick(holder.itemView, position);
        }
      }
    });*/
  }
}

class ViewHolder_GuessYourLike extends RecyclerView.ViewHolder {

  TextView textView_type;
  TextView textView_name;
  TextView textView_date;
  TextView textView_status;
  TextView textView_contextMark;
  TextView textView_contextPreview;

  public ViewHolder_GuessYourLike(View itemView) {
    super(itemView);
    textView_type = (TextView) itemView.findViewById(R.id.textView_item_guessYourLike_guessData_type);
    textView_name = (TextView) itemView.findViewById(R.id.textView_item_guessYourLike_guessData_name);
    textView_date = (TextView) itemView.findViewById(R.id.textView_item_guessYourLike_guessData_date);
    textView_status = (TextView) itemView.findViewById(R.id.textView_item_guessYourLike_guessData_status);
    textView_contextMark = (TextView) itemView.findViewById(R.id.textView_item_guessYourLike_guessData_contextMark);
    textView_contextPreview = (TextView) itemView.findViewById(R.id.textView_item_guessYourLike_guessData_contextPreview);
  }
}